'\" te
.\" Copyright (c) 2007, Sun Microsystems, Inc.  All Rights Reserved
.\" Copyright 1989 AT&T
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH PERROR 3C "Jul 12, 2007"
.SH NAME
perror, errno \- print system error messages
.SH SYNOPSIS
.LP
.nf
#include <stdio.h>

\fBvoid\fR \fBperror\fR(\fBconst char *\fR\fIs\fR)
.fi

.LP
.nf
#include <errno.h>

int errno;
.fi

.SH DESCRIPTION
.sp
.LP
The \fBperror()\fR function produces a message on the standard error output
(file descriptor 2) describing the last error encountered during a call to a
system or library function. The argument string \fIs\fR is printed, followed by
a colon and a blank, followed by the message and a \fBNEWLINE\fR character.  If
\fIs\fR is a null pointer or points to a null string, the colon is not printed.
The argument string should include the name of the program that incurred the
error. The error number is taken from the external variable \fBerrno\fR, which
is set when errors occur but not cleared when non-erroneous calls are made. See
\fBIntro\fR(2).
.sp
.LP
In the case of multithreaded applications, the \fB-mt\fR option must be
specified on the command line at compilation time (see \fBthreads\fR(7)). When
the \fB-mt\fR option is specified, \fBerrno\fR becomes a macro that enables
each thread to have its own \fBerrno\fR. This \fBerrno\fR macro can be used on
either side of the assignment as though it were a variable.
.SH USAGE
.sp
.LP
Messages printed from this function are in the native language specified by the
\fBLC_MESSAGES\fR locale category.  See \fBsetlocale\fR(3C).
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Standard
_
MT-Level	MT-Safe
.TE

.SH SEE ALSO
.sp
.LP
.BR Intro (2),
.BR fmtmsg (3C),
.BR gettext (3C),
.BR setlocale (3C),
.BR strerror (3C),
.BR attributes (7),
.BR standards (7),
.BR threads (7)
